/*************************************************************************
	> File Name: faketee.c
	> Author: Angel Criss
	> Mail: abbytsing@gmail.com 
	> Created Time: Sat 08 Mar 2014 06:17:00 PM CST
 ************************************************************************/

#include<stdio.h>
#include<sys/stat.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<fcntl.h>
int main(int argc, char *argv[])
{
    int len,fileo,filew,filer,i=0,c;
    char *buf;
    len=sizeof(argv[2]);
    if(argc<3)
    {
        perror("too less arguments");
        exit(0);
    }
    fileo=open(argv[1],O_RDWR|O_CREAT,00644);
    if(fileo==-1)
    {
        perror("cannot open standard input");
        exit(1);
    }
    buf=malloc(len);
        filew=write(fileo,&argv[2],len);

        if(filew==-1)
            perror("cannot write");
        lseek(fileo,0,SEEK_SET);
        filer=read(fileo,buf,len);

        if(filer==0)
             perror("end of file\n");

        else if(filer==-1)

            perror("filer");
        else
            printf("%s",*buf);
}
